<?php
namespace app\lawcase\validate;

use think\Validate;

class CaseCauseCheck extends Validate
{
    // 验证规则
    protected $rule = [
        'name' => 'require|max:100',
        'parent_id' => 'number|egt:0',
        'sort' => 'number|between:0,9999',
        'id' => 'require|number|gt:0',
    ];
    
    // 错误消息
    protected $message = [
        'name.require' => '案由名称不能为空',
        'name.max' => '案由名称最多不能超过100个字符',
        'parent_id.number' => '父级ID必须是数字',
        'parent_id.egt' => '父级ID必须大于等于0',
        'sort.number' => '排序值必须是数字',
        'sort.between' => '排序值必须在0-9999之间',
        'id.require' => 'ID不能为空',
        'id.number' => 'ID必须是数字',
        'id.gt' => 'ID必须大于0',
    ];
    
    // 验证场景
    protected $scene = [
        'add' => ['name', 'parent_id', 'sort'],
        'edit' => ['id', 'name', 'parent_id', 'sort'],
    ];
}